
import { request } from '../../utils/request';
Page({
  data:{keyword:'', items:[]},
  onLoad(){ this.fetch(); },
  onKey(e){ this.setData({keyword:e.detail.value}); },
  async fetch(){ const res = await request('/api/items'); this.setData({items: res.data.content || []}); },
  async search(){ const res = await request('/api/items?keyword='+this.data.keyword); this.setData({items: res.data.content || []}); },
  go(e){ const id=e.currentTarget.dataset.id; wx.navigateTo({url:'/pages/item/item?id='+id}); }
});
